package com.xjc.business.controller.schadmin;


import com.xjc.business.entity.po.schadmin.SchApplyPo;
import com.xjc.business.entity.vo.schadmin.SchDetailVo;
import com.xjc.business.service.SchoolApplysService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 徐锦程
 * 时间:2025-01-25 20:46
 */
@RestController
@RequestMapping("/sch_admin/school_apply")
public class SchoolApplyController {

    @Autowired
    SchoolApplysService schoolApplysService;

    /**
     * 申请开通学校
     * @param schApplyPo 学校信息
     * @return 反馈
     */
    @PostMapping("/apply")
    public Result<Integer> doApply(@RequestBody(required = false) SchApplyPo schApplyPo) {
        if (schApplyPo == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }
        return schoolApplysService.doApply(schApplyPo);
    }

    /**
     * 获取申请中的学校详情
     * @param id 学校管理员id
     * @return 学校详情
     */
    @GetMapping("/detail/{id}")
    public Result<SchDetailVo> getSchoolInfo(@PathVariable(value = "id",required = false) Integer id) {
        if (id == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return schoolApplysService.getApplySchoolInfo(id);
    }
}
